import React, { Component } from "react";

class Child1 extends Component {
  render() {
    return (
      <div>
        child1组件 - {this.props.name} - {this.props.age}
      </div>
    );
  }
}

const Child2 = (props) => {
  const fn = () => {
    // props.num = 3;
  };

  return (
    <div>
      child2组件 - {props.num} - <button onClick={fn}>btn</button>
    </div>
  );
};

class App extends Component {
  render() {
    return (
      <>
        <h2>props</h2>
        {/* 父传子也是使用自定义属性，使用props接收 */}
        {/* react也需要遵循单向数据流 */}
        <Child1 name="pengshao" age="30" />
        <Child2 num="1" />
      </>
    );
  }
}

export default App;
